/**
 * 
 */
package com.huawei.esdk.tp.cxf.enumgen;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * <一句话功能简述>
 * <p>
 * <功能详细描述>
 * <p>
 * @author  gWX169839
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class ContinuousPresenceModeEXMapping
{
    private static ContinuousPresenceModeEXMapping instance = null;
    
    public final static int MIN = 0;
    
    public final static int MAX = 49;
    
    private List<ContinuousPresenceMode> modeList = initModeList();
    
    private HashMap<String, Integer> modeValues = initModeValueList();
    
    public static ContinuousPresenceModeEXMapping getInstance()
    {
        if (null == instance)
        {
            instance = new ContinuousPresenceModeEXMapping();
        }
        return instance;
    }
    
    private ContinuousPresenceModeEXMapping()
    {
        
    }
    
    private static List<ContinuousPresenceMode> initModeList()
    {
        List<ContinuousPresenceMode> modeList = new ArrayList<ContinuousPresenceMode>();
        for (ContinuousPresenceMode mode : ContinuousPresenceMode.values())
        {
            modeList.add(mode);
        }
        return modeList;
    }
    
    private static HashMap<String, Integer> initModeValueList()
    {
        HashMap<String, Integer> modeValues = new HashMap<String, Integer>();
        int i = 0;
        
        for (ContinuousPresenceMode mode : ContinuousPresenceMode.values())
        {
            modeValues.put(mode.value(), i);
            i++;
        }
        
        return modeValues;
    }
    
    public ContinuousPresenceMode int2Enum(Integer num)
    {
        if (num > modeList.size() || num < 0)
        {
            return null;
        }
        else
        {
            return modeList.get(num);
        }
    }
    
    public Integer enum2Int(String value)
    {
        return modeValues.get(value);
    }
}
